<template>
  <div class="newsdetail">
    <h2 style="text-align: center">{{ detail.title }}</h2>
    <div v-if="detail.id" style="padding: 20px; text-align: center">
      发布时间：{{ detail.create_time }}
    </div>
    <div style="padding: 0 20px" v-html="detail.content"></div>
  </div>
</template>

<script setup>
import { useRoute } from 'vue-router';
import { onMounted, ref } from 'vue';
import { getNewsDetail } from '../../api/material';
const route = useRoute();
const id = ref(route.query.id);
const detail = ref({});

onMounted(() => {
  if (id.value) {
    getNewsDetail({
      id: id.value,
    }).then((res) => {
      console.log(res);
      detail.value = res.data.data;
    });
  }
});
</script>

<style lang="less">
.newsdetail {
  padding-top: 100px;
}
</style>
